package com.gaoyi.crm.db.entity;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.room.Entity;
import androidx.room.Ignore;

import com.gaoyi.crm.db.CrmDatabase;

import java.util.Date;
import java.util.Objects;

@Entity(tableName = CrmDatabase.TABLE_ITEM_NO_STORE)
public class ItemNoStore extends BaseEntity implements Parcelable {
    private String itemNo;
    private String categoryId;
    private String detail;
    private String remark;
    private String descrip;
    private String designNo;
    private float sketchSize;

    private Date syncedAt;
    private int syncedStatus;

    @Ignore
    private Category category;

    @Ignore
    private String categoryName;

    @Ignore
    private boolean isCheck;

    public ItemNoStore() {
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ItemNoStore that = (ItemNoStore) o;
        return Float.compare(that.sketchSize, sketchSize) == 0 && syncedStatus == that.syncedStatus && isCheck == that.isCheck && Objects.equals(itemNo, that.itemNo) && Objects.equals(categoryId, that.categoryId) && Objects.equals(detail, that.detail) && Objects.equals(remark, that.remark) && Objects.equals(descrip, that.descrip) && Objects.equals(designNo, that.designNo) && Objects.equals(syncedAt, that.syncedAt) && Objects.equals(category, that.category) && Objects.equals(categoryName, that.categoryName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(itemNo, categoryId, detail, remark, descrip, designNo, sketchSize, syncedAt, syncedStatus, category, categoryName, isCheck);
    }

    protected ItemNoStore(Parcel in) {
        itemNo = in.readString();
        categoryId = in.readString();
        detail = in.readString();
        remark = in.readString();
        descrip = in.readString();
        designNo = in.readString();
        sketchSize = in.readFloat();
        syncedStatus = in.readInt();
        category = in.readParcelable(Category.class.getClassLoader());
        categoryName = in.readString();
        isCheck = in.readByte() != 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(itemNo);
        dest.writeString(categoryId);
        dest.writeString(detail);
        dest.writeString(remark);
        dest.writeString(descrip);
        dest.writeString(designNo);
        dest.writeFloat(sketchSize);
        dest.writeInt(syncedStatus);
        dest.writeParcelable(category, flags);
        dest.writeString(categoryName);
        dest.writeByte((byte) (isCheck ? 1 : 0));
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<ItemNoStore> CREATOR = new Creator<ItemNoStore>() {
        @Override
        public ItemNoStore createFromParcel(Parcel in) {
            return new ItemNoStore(in);
        }

        @Override
        public ItemNoStore[] newArray(int size) {
            return new ItemNoStore[size];
        }
    };

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public boolean isCheck() {
        return isCheck;
    }

    public void setCheck(boolean check) {
        isCheck = check;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public Date getSyncedAt() {
        return syncedAt;
    }

    public void setSyncedAt(Date syncedAt) {
        this.syncedAt = syncedAt;
    }

    public int getSyncedStatus() {
        return syncedStatus;
    }

    public void setSyncedStatus(int syncedStatus) {
        this.syncedStatus = syncedStatus;
    }

    public String getItemNo() {
        return itemNo;
    }

    public void setItemNo(String itemNo) {
        this.itemNo = itemNo;
    }

    public String getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(String categoryId) {
        this.categoryId = categoryId;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getDescrip() {
        return descrip;
    }

    public void setDescrip(String descrip) {
        this.descrip = descrip;
    }

    public String getDesignNo() {
        return designNo;
    }

    public void setDesignNo(String designNo) {
        this.designNo = designNo;
    }

    public float getSketchSize() {
        return sketchSize;
    }

    public void setSketchSize(float sketchSize) {
        this.sketchSize = sketchSize;
    }
}
